package gui.requestDetail;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

import javax.swing.JScrollPane;
import javax.swing.JTextPane;

import model.basics.Request;
import org.jdesktop.application.Application;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class RequestComparation extends javax.swing.JPanel {
	private JScrollPane orderScrollPane;
	private JButton backButton;
	private JScrollPane originalReqScrollPane;
	private JCheckBox vsyncCheckBox;
	private JTextPane originalReqTextPane;
	private JTextPane orderTextPane;
	private Request originalReq, req;
	private JPanel panel;

	/**
	 * Auto-generated main method to display this JPanel inside a new JFrame.
	 * 
	 * @param originalReq
	 * @param req
	 */

	public RequestComparation() {
		super();
		initGUI();
	}

	public JTextPane getOriginalReqTextPane() {
		return originalReqTextPane;
	}



	public JTextPane getReqActualTextPane() {
		return orderTextPane;
	}

	public void setReqActualTextPane(JTextPane reqActualTextPane) {
		this.orderTextPane = reqActualTextPane;
	}

	public Request getOriginalReq() {
		return originalReq;
	}

	public void setOriginalReq(Request originalReq) {
		this.originalReq = originalReq;
	}

	public Request getReq() {
		return req;
	}

	public void setReq(Request req) {
		this.req = req;
	}

	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(636, 270));
			this.setLayout(null);
			{
				orderScrollPane = new JScrollPane();
				this.add(orderScrollPane);
				orderScrollPane.setBounds(12, 12, 300, 200);
				orderScrollPane.setBorder(BorderFactory.createTitledBorder("Order Info."));
				
				// set vertical sync
				orderScrollPane.getVerticalScrollBar().addAdjustmentListener(
						new AdjustmentListener() {
							public void adjustmentValueChanged(AdjustmentEvent e) {
								if (vsyncCheckBox.isSelected())
									originalReqScrollPane
											.getVerticalScrollBar()
											.setValue(
													orderScrollPane
															.getVerticalScrollBar()
															.getValue());
							}
						});
				{
					orderTextPane = new JTextPane();
					orderScrollPane.setViewportView(orderTextPane);
					orderTextPane.setPreferredSize(new java.awt.Dimension(166, 199));
					orderTextPane.setEditable(false);
					orderTextPane.setName("orderTextPane");
				}
			}
			{
				originalReqScrollPane = new JScrollPane();
				this.add(originalReqScrollPane);
				originalReqScrollPane.setBounds(324, 12, 300, 200);
				originalReqScrollPane.setBorder(BorderFactory.createTitledBorder("First Request Info."));
				
				// set vertical sync
				originalReqScrollPane.getVerticalScrollBar()
						.addAdjustmentListener(new AdjustmentListener() {
							public void adjustmentValueChanged(AdjustmentEvent e) {
								if (vsyncCheckBox.isSelected())
									orderScrollPane
											.getVerticalScrollBar()
											.setValue(
													originalReqScrollPane
															.getVerticalScrollBar()
															.getValue());
							}
						});

				{
					originalReqTextPane = new JTextPane();
					originalReqScrollPane.setViewportView(originalReqTextPane);
					originalReqTextPane.setPreferredSize(new java.awt.Dimension(166, 199));
					originalReqTextPane.setEditable(false);
					orderTextPane.setName("originalReqTextPane");
				}
			}
			{
				vsyncCheckBox = new JCheckBox();
				this.add(vsyncCheckBox);
				vsyncCheckBox.setBounds(511, 242, 114, 18);
				vsyncCheckBox.setName("jCheckBox1");
			}
			{
				backButton = new JButton();
				this.add(backButton);
				backButton.setBounds(12, 241, 64, 21);
				backButton.setName("backButton");
				backButton.addActionListener(new BackListener());
			}
			Application.getInstance().getContext().getResourceMap(getClass())
					.injectComponents(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public class BackListener implements ActionListener{
		public void actionPerformed(ActionEvent e) {
			((CardLayout)panel.getLayout()).previous(panel);
		}
	}

	public void setPanel(JPanel orderPanel) {
		this.panel = orderPanel;
		
	}
}
